
// 购物车图标点击事件
$("#bag-a-btn").click(function () {
    if ($(".bag-wrapper").css("display") === "none") {
        $(".bag-wrapper").css("display", "block");
    } else {
        $(".bag-wrapper").css("display", "none");
    }
});


//搜索框显示与取消  并且开启和关闭蒙版
$("#search-btn").click(function show_search( ) {
    $(".nav-list .search-outter-wrapper").show("normal");
    $(".lift-wrapper").fadeOut("normal");
    $(".mask-layer").show();   
    $(".nav-list .search-outter-wrapper").siblings("li").hide("normal");
    $("body").css("overflow-y","hidden");//禁用滚动条
  
});

$("#cancel-search").click(function show_search( ) {
    $(".nav-list .search-outter-wrapper").hide("normal");
    $(".nav-list .search-outter-wrapper").siblings("li").show("normal"); 
    $(".mask-layer").hide();    
    $(".lift-wrapper").fadeIn("normal");
    $("body").css("overflow-y","scroll");//开启滚动条

});

// 窗口滚动到一定距离时 让搜索栏显示
$(window).on("scroll",function() {
    if(parseInt($(document).scrollTop())>300){
        $(".fixed-search").slideDown(300);
    }else {
        $(".fixed-search").slideUp(100);
    }
});

$("#fixed-search-text").focusin(function() {
    $(".fixed-search .search-list-wrapper").stop(true).fadeIn(300);
});

$("#fixed-search-text").focusout(function() {
    $(".fixed-search .search-list-wrapper").stop(true).fadeOut(300);
})

//移入让按钮显示 
$(".cards-shelf-scroller").hover(function () {
    $(this).find("button").css("opacity", "1");
}, function () {
    $(this).find("button").css("opacity", "0");

});
$(".cards-pointer-l,.cards-pointer-r").mouseenter(function () {
    $(this).css("opacity", "1");
});

//按按钮让卡片移动 

$(".cards-pointer-r").click(function () {
    let left = $(this).siblings("ul").css("left");
    let add_l = -300;
    left = parseInt(left) + add_l;

    $(this).siblings("ul").css("left", left + "px");
});

$(".cards-pointer-l").click(function () {
    let left = $(this).siblings("ul").css("left");
    if (parseInt(left) < 0) {
        let add_l = 300;
        left = parseInt(left) + add_l;
        $(this).siblings("ul").css("left", left + "px");
    } else {
        return false;
    }

})
